<?php
/**
 * ============================================================================
 * Doxt Version: 1.0           
 * Web: http:
 * Copyright (C) 2007 - 2010 Doxt Technology Inc., All Rights Reserved.
 * ---------------------------------------------
 * $Date: 2008.4.8
*/

  if ($_POST["btn_sub"])
  {  
	$time=date('Y-m-d H:i:s');
    $c = work_str($_POST["c"], 1);		
   	$name = work_str($_POST["name"], 1);				
	$id = work_str($_POST["id"], 1);				
	$note= work_str($_POST['note'],1);				
	$password= work_str($_POST['pass'],1);
	$password=md5($password);
	if($c==1)
	{
		$query = "UPDATE $TBL_ADMIN SET name='$name',note='$note',password='$password' where id=$id";
	}else{	
		$query = "UPDATE $TBL_ADMIN SET name='$name',note='$note' where id=$id";
	}
    $res = mysql_query($query) or die(mysql_error());
	MyNotice("高級管理員編輯成功", 2, "list4.php");
	exit(0);
  }
  $NEWS_ID = intval( $_GET["id"] );
  if (empty($NEWS_ID)) exit(0);

  $query = "SELECT * FROM $TBL_ADMIN WHERE id='$NEWS_ID'";
  $result = mysql_query( $query ) or die(mysql_error());
  $rows = mysql_fetch_array( $result);
  
  /* 指定模板文件 */
  $tpl -> set_file(array("main" => "edit_news.htm"));  
  $tpl -> set_block("main","TYPE_LIST","type_list"); 
  $tpl -> set_var(array(
                         "mem_id" => $rows['mem_id'],
						 "name" => $rows['name'],
						 "note" => $rows['note'],
						 "id" => $rows['id'],						 
						 "NEWS_ID" => $NEWS_ID,
                       ));
  $tpl -> set_var( $conf);
  $tpl -> parse("Output", "main");
  $tpl -> p("Output");
  exit(0);
?>